#ifdef COMPILE_OPENGL

#include "CBL_Debug.h"
#include "COGL_ParameterAtomic.h"
#include <OpenGL/OpenGL.h>
#include <OpenGL/glext.h>
#include "COGL_Extensions.h"

CB_SUBNAMESPACE_START(OpenGL)

int CMatrix4x4ParameterAtomic::Bind()
{
	glUniformMatrix4fv(GetResource(), GetNumRegisters() / 4, false, (GLfloat*)m_ValueArray);
	return glGetError();    
}

// -----------------------------------------------------------------------

int CFloatParameterAtomic::Bind()
{   
	switch (m_ComponentType)
    {	
    case GL_FLOAT:
        glUniform1fv(GetResource(), GetNumRegisters(), (GLfloat*)m_ValueArray);
        break;

    case GL_FLOAT_VEC2:
        glUniform2fv(GetResource(), GetNumRegisters(), (GLfloat*)m_ValueArray);
        break;

    case GL_FLOAT_VEC3:
        glUniform3fv(GetResource(), GetNumRegisters(), (GLfloat*)m_ValueArray);
        break;
    
    case GL_FLOAT_VEC4:
        glUniform4fv(GetResource(), GetNumRegisters(), (GLfloat*)m_ValueArray);
		break;
        
    default:
    	return -1;
    }
	
    return glGetError(); 
}

// -----------------------------------------------------------------------

int CIntParameterAtomic::Bind()
{    
	glUniform4iv(GetResource(), GetNumRegisters(), (GLint*)m_ValueArray);
	return glGetError();
}

// -----------------------------------------------------------------------

int CBoolParameterAtomic::Bind()
{    
	glUniform4iv(GetResource(), GetNumRegisters(), (GLint*)m_ValueArray);
	return glGetError();
}

CB_SUBNAMESPACE_END

#endif